package com.aistar.line.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description: java类作用描述:收藏表的CRUD
 * @Author: tyg
 * @CreateDate: 2019/7/2 0002
 * @Version: 1.0
 */
public interface CollectMapper {
    /**
     * 根据路线id查找点赞用户的id
     *
     * @param id
     * @return
     */
    @Select("select user_id from collect where line_id = #{id}")
    List<String> findById(String id);

    /**
     * 根据路线和用户id删除点赞关系
     *
     * @param lid
     * @param uid
     * @return
     */
    @Delete("delete from collect where line_id = #{lid} and user_id = #{uid}")
    boolean delByLineIdAndUserId(@Param("lid") String lid, @Param("uid") String uid);

    /**
     * 添加一个点赞关系
     * @param cid
     * @param lid
     * @param uid
     * @return
     */
    @Insert("insert into collect values(#{cid},#{lid},#{uid})")
    boolean addCollect(@Param("cid") String cid, @Param("lid") String lid, @Param("uid") String uid);

    /**
     * 根据路线id查找点赞用户的id
     *
     * @param id
     * @return
     */
    @Select("select line_id from collect where user_id = #{id}")
    List<String> findByUid(String id);
}
